#ifndef H_UTIL
#define H_UTIL

void
DebugPrintf(const wchar_t *fmt, ...);

void
DebugMessageBox(const wchar_t *fmt, ...);

#define IFR(expr)                                                       \
    {                                                                   \
        hr = (expr);                                                    \
        if (FAILED(hr)) {                                               \
            DebugPrintf(L"%S %S failed %x\n", __FUNCTION__, #expr, hr); \
            return hr;                                                  \
        }                                                               \
    }                                                                   \

#define IFMB(expr)                                                        \
    {                                                                     \
        hr = (expr);                                                      \
        if (FAILED(hr)) {                                                 \
            DebugMessageBox(L"%S %S failed %x", __FUNCTION__, #expr, hr); \
        }                                                                 \
    }                                                                     \

#define SAFE_RELEASE(V) \
    if (V) {            \
        V->Release();   \
        V = NULL;       \
    }                   \

#define SAFE_DELETE_ARRAY(V) \
    delete[] V;              \
    V = NULL;                \

#define SAFE_DELETE(V) \
    delete V;          \
    V = NULL;          \


const wchar_t *
Title(void);

#define FILE_PATH_NUM (256)

#endif H_UTIL
